<span page-title ng-model="host">{{ 'Packages for: ' | translate }} {{ host.name }}</span>

<section ng-hide="denied('edit_hosts', host)" bst-feature-flag="remote_actions">
  <h4 translate>Package Actions</h4>
  <p bst-alert="info" ng-hide="remoteExecutionPresent">
    <span translate>
      The remote execution feature is required to manage packages on this Host.
    </span>
  </p>
  <section>
    <div class="row">
      <form ng-submit="performPackageAction(packageAction.actionType, packageAction.term)" role="form">

        <div class="form-group col-sm-2">
          <select class="form-control" ng-model="packageAction.actionType" name="remote_action" required>
            <option value="packageInstall" translate>Package Install</option>
            <option value="packageUpdate" translate>Package Update</option>
            <option value="packageRemove" translate>Package Remove</option>
          </select>
        </div>

        <div class="form-group col-sm-5">
          <div class="input-group">
            <input class="form-control"
                   type="text"
                   placeholder="{{ 'Package/Group Name' | translate}}"
                   ng-model="packageAction.term"/>

            <span uib-dropdown class="input-group-btn">
              <button class="btn btn-primary" type="button"
                      ng-click="performPackageAction(packageAction.actionType, packageAction.term)"
                      ng-hide="denied('edit_hosts', host)"
                      ng-disabled="working || packageAction.term === undefined || packageAction.term.length === 0 || !remoteExecutionPresent"
                      translate>
                Perform
              </button>
              <button uib-dropdown-toggle class="btn btn-default"
                      ng-hide="!remoteExecutionPresent || denied('edit_content_hosts', contentHost)"
                      ng-disabled="working || packageAction.term === undefined || packageAction.term.length === 0"
                      type="button" id="use-remote-execution">
                <span class="caret"></span>
              </button>
              <ul uib-dropdown-menu role="menu" aria-labelledby="use-remote-execution">
                <li role="presentation"><a ng-click="performViaRemoteExecution(packageAction.actionType, packageAction.term, false)" role="menuitem" tabindex="-1" href="#" translate>via remote execution</a></li>
                <li role="presentation"><a ng-click="performViaRemoteExecution(packageAction.actionType, packageAction.term, true)" role="menuitem" tabindex="-1" href="#" translate>via remote execution - customize first</a></li>
              </ul>
            </span>
          </div>
        </div>

        <div class="form-group">
          <button class="btn btn-default" type="button"
                  translate
                  ng-disabled="working || !remoteExecutionPresent"
                  ng-click="updateAll()">
            Update All Packages
          </button>
        </div>
      </form>
    </div>
  </section>
</section>
